30. Exercise: Add a Touch Selector
Add Touch Selectors
Create two different touch selectors. One called today_touch_selector that turns colorPrimaryDark when the today list item layout is selected, and one called touch_selector that turns the activated color (defined earlier) when the general, small list item is selected.
Remember the selected states are as follows: android:state_pressed, android:state_activated, and android:state_selected.
Exercise Code
Exercise: S12.03-Exercise-TouchSelectors
Add a Touch Selector
SOLUTION:
- Create a touch selector called touch_selector for the list item
- Use touch_selector as the background for the list item
- Create a touch selector called today_touch_selector for the today list item layout
- Replace the background color for the today list item with today_touch_selector